﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using DomainDriver.DomainModeling.DomainObjects;

namespace AutomotivePricingModel.Dealers
{
    public class DealerVehicleRelation : DomainObjectBase<DealerVehicleRelation>
    {
        private Guid m_ParentDealerId;
        private Guid m_RelatedVehicleId;
        private int m_VehicleCount;

        public DealerVehicleRelation()
            : this(Guid.Empty, Guid.Empty, 0)
        { }

        public DealerVehicleRelation(Guid parentDealerId, Guid relatedVehicleId, int vehicleCount)
        {
            m_ParentDealerId = parentDealerId;
            m_RelatedVehicleId = relatedVehicleId;
            m_VehicleCount = vehicleCount;
        }

        [Key]
        [DatabaseGenerated(DatabaseGeneratedOption.None)]
        [Column(Order = 0)]
        public Guid ParentDealerId
        {
            get { return m_ParentDealerId; }
            set { m_ParentDealerId = value; }
        }

        [Key]
        [DatabaseGenerated(DatabaseGeneratedOption.None)]
        [Column(Order = 1)]
        public Guid RelatedVehicleId
        {
            get { return m_RelatedVehicleId; }
            set { m_RelatedVehicleId = value; }
        }

        [Required]
        [Column(Order = 2)]
        public int VehicleCount
        {
            get { return m_VehicleCount; }
            set { m_VehicleCount = value; }
        }

        #region DomainObject Methods

        public override DealerVehicleRelation Copy()
        {
            DealerVehicleRelation copy = new DealerVehicleRelation();
            CopyTo(copy);
            return copy;
        }

        public override void CopyTo(DealerVehicleRelation otherObject)
        {
            otherObject.m_ParentDealerId = m_ParentDealerId;
            otherObject.m_RelatedVehicleId = m_RelatedVehicleId;
            otherObject.m_VehicleCount = m_VehicleCount;
        }

        public override bool Equals(DealerVehicleRelation otherObject)
        {
            if (otherObject.m_ParentDealerId != m_ParentDealerId)
            { return false; }
            if (otherObject.m_RelatedVehicleId != m_RelatedVehicleId)
            { return false; }
            if (otherObject.m_VehicleCount != m_VehicleCount)
            { return false; }
            return true;
        }

        #endregion
    }
}